﻿using System.Web.Mvc;
using ORM.Business.Interfaces;
using ORM.Areas.Admin.ViewModels.AdminHome;
using ORM.Models;
using ORM.Web.Models;

namespace ORM.Areas.Admin.Controllers
{
    public class AdminHomeController : AdminControllerBase
    {
        //
        // GET: /Admin/AdminHome/

        private IApplicationRepository _repository;

        public AdminHomeController(IApplicationRepository repository)
        {
            _repository = repository;
        }

        public ActionResult Index()
        {
            ReportedStatisticsViewModel vm = new ReportedStatisticsViewModel();
            var feedback = _repository.GetReportedStatistics();
            if (!feedback.Success)
            {
                SetMessage(feedback.Message, MessageType.Error);
                return View();
            }
            else
            {
                vm.AllUserNumber = feedback.AllUserNumber;
                vm.GuideNumber = feedback.GuideNumber;
                vm.QuestionNumber = feedback.QuestionNumber;
                vm.AnswerNumber = feedback.AnswerNumber;
                vm.VisitorNumber = feedback.VisitorNumber;
                vm.VisitorsToday = feedback.VisitorsToday;
                vm.CommentNumber = feedback.CommentNumber;
                vm.ReportedQuestionsNumber = feedback.ReportedQuestionsNumber;
                vm.ReportedAnswersNumber = feedback.ReportedAnswersNumber;

                return View(vm);
            }         
        }

    }
}
